package com.demon.activitychange.xposed;

import android.text.TextUtils;

public class PayUtils {

    private static PayUtils mPayUtils;

    public static PayUtils getInstance() {
        if (mPayUtils == null) {
            synchronized (PayUtils.class) {
                if (mPayUtils == null) {
                    mPayUtils = new PayUtils();
                }
            }
        }
        return mPayUtils;
    }

    public static String getMidText(String str, String str2, String str3) {
        try {
            int start = str.indexOf(str2);
            if (start == -1) {
                return "";
            }

            int indexOf = start + str2.length();
            if (TextUtils.isEmpty(str3)) {
                return str.substring(indexOf);
            }
            return str.substring(indexOf, str.indexOf(str3, indexOf));
        } catch (Exception e) {
            e.printStackTrace();
        }

        return "";
    }

    public static boolean isOrderNeedRetry(String error) {
        if (TextUtils.isEmpty(error)) {
            return true;
        } else if (error.contains("订单重复上传")) {
            return false;
        } else if (error.contains("订单已支付")) {
            return false;
        } else if (error.contains("订单不存在")) {
            return false;
        } else if (error.contains("二维码不存在")) {
            return false;
        }

        return true;
    }
}
